﻿using B.S.DataBase.MyProject.Domain.BOM;
using B.S.DataBase.MyProject.ErrorCode;
using B.S.DataBase.MyProject.Infrastructure.Interface;
using MediatR;
using T.E.ERP.Read.API.Applicantions.Command.BomCOmmand;

namespace T.E.ERP.Read.API.Applicantions.CommandHandler.BomConnamdHandler
{

    public class ReGetProcessCommandHandler : IRequestHandler<ReGetProcessCommand, APIResult<ProcessInfo>>
    {
        private readonly IBaseRepository<ProcessInfo> proRep;
        public ReGetProcessCommandHandler(IBaseRepository<ProcessInfo> proRep)
        {
            this.proRep = proRep;
        }
        public Task<APIResult<ProcessInfo>> Handle(ReGetProcessCommand request, CancellationToken cancellationToken)
        {
            APIResult<ProcessInfo> result = new APIResult<ProcessInfo>();
            var list= proRep.GetAll().Result.Where(x=>x.ProcessId==request.ProcessId).FirstOrDefault();
            result.Code = APIEnum.成功;
            result.Msg = APIEnum.查询成功.ToString();
            result.data = list;
            return Task.FromResult(result);
        }
    }
}
